package org.htmlparser.parserapplications;

import java.io.File;
import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;
import javax.swing.JFileChooser;
import javax.swing.JOptionPane;
import org.htmlparser.filters.AndFilter;
import org.htmlparser.filters.HasAttributeFilter;
import org.htmlparser.filters.NotFilter;
import org.htmlparser.filters.OrFilter;
import org.htmlparser.filters.TagNameFilter;

public class WikiCapturer extends SiteCapturer
{
  public static void main(String[] paramArrayOfString)
    throws MalformedURLException, IOException
  {
    WikiCapturer localWikiCapturer = new WikiCapturer();
    if (paramArrayOfString.length <= 0)
    {
      String str = (String)JOptionPane.showInputDialog(null, "Enter the URL to capture:", "Web Site", -1, null, null, "http://htmlparser.sourceforge.net/wiki");
      if (str != null)
      {
        localWikiCapturer.setSource(str);
        if (1 < paramArrayOfString.length)
          break label392;
        URL localURL = new URL(localWikiCapturer.getSource());
        File localFile = new File(new File(new File("." + File.separator), localURL.getHost() + File.separator).getCanonicalPath());
        JFileChooser localJFileChooser = new JFileChooser(localFile);
        localJFileChooser.setDialogType(1);
        localJFileChooser.setFileSelectionMode(1);
        localJFileChooser.setSelectedFile(localFile);
        localJFileChooser.setMultiSelectionEnabled(false);
        localJFileChooser.setDialogTitle("Target Directory");
        if (localJFileChooser.showSaveDialog(null) != 0)
          break label385;
        localWikiCapturer.setTarget(localJFileChooser.getSelectedFile().getAbsolutePath());
        if (2 < paramArrayOfString.length)
          break label409;
        Object[] arrayOfObject = new Object[2];
        arrayOfObject[0] = Boolean.TRUE;
        arrayOfObject[1] = Boolean.FALSE;
        Boolean localBoolean = (Boolean)JOptionPane.showInputDialog(null, "Should resources be captured:", "Capture Resources", -1, null, arrayOfObject, Boolean.TRUE);
        if (localBoolean == null)
          break label402;
        localWikiCapturer.setCaptureResources(localBoolean.booleanValue());
      }
    }
    while (true)
    {
      while (true)
      {
        while (true)
        {
          while (true)
          {
            while (true)
            {
              while (true)
              {
                localWikiCapturer.setFilter(new NotFilter(new OrFilter(new AndFilter(new TagNameFilter("DIV"), new HasAttributeFilter("id", "navbar")), new OrFilter(new AndFilter(new TagNameFilter("DIV"), new HasAttributeFilter("id", "actionbar")), new AndFilter(new TagNameFilter("DIV"), new HasAttributeFilter("id", "xhtml-validator"))))));
                localWikiCapturer.capture();
                System.exit(0);
                return;
                System.exit(1);
              }
              localWikiCapturer.setSource(paramArrayOfString[0]);
            }
            label385: System.exit(1);
          }
          label392: localWikiCapturer.setTarget(paramArrayOfString[1]);
        }
        label402: System.exit(1);
      }
      label409: localWikiCapturer.setCaptureResources(Boolean.valueOf(paramArrayOfString[2]).booleanValue());
    }
  }

  protected boolean isToBeCaptured(String paramString)
  {
    boolean bool = super.isToBeCaptured(paramString);
    if (bool)
    {
      if (!(paramString.endsWith("PhpWikiAdministration")))
        break label23;
      bool = false;
    }
    while (true)
    {
      do
        while (true)
        {
          while (true)
          {
            while (true)
            {
              while (true)
              {
                while (true)
                {
                  while (true)
                  {
                    while (true)
                    {
                      while (true)
                      {
                        while (true)
                        {
                          while (true)
                          {
                            while (true)
                            {
                              while (true)
                              {
                                while (true)
                                {
                                  while (true)
                                  {
                                    while (true)
                                    {
                                      while (true)
                                      {
                                        while (true)
                                        {
                                          while (true)
                                          {
                                            return bool;
                                            label23: if (!(paramString.endsWith("PhpWikiDocumentation")))
                                              break;
                                            bool = false;
                                          }
                                          if (!(paramString.endsWith("TextFormattingRules")))
                                            break;
                                          bool = false;
                                        }
                                        if (!(paramString.endsWith("NewMarkupTestPage")))
                                          break;
                                        bool = false;
                                      }
                                      if (!(paramString.endsWith("OldMarkupTestPage")))
                                        break;
                                      bool = false;
                                    }
                                    if (!(paramString.endsWith("OldTextFormattingRules")))
                                      break;
                                    bool = false;
                                  }
                                  if (!(paramString.endsWith("PgsrcTranslation")))
                                    break;
                                  bool = false;
                                }
                                if (!(paramString.endsWith("HowToUseWiki")))
                                  break;
                                bool = false;
                              }
                              if (!(paramString.endsWith("MoreAboutMechanics")))
                                break;
                              bool = false;
                            }
                            if (!(paramString.endsWith("AddingPages")))
                              break;
                            bool = false;
                          }
                          if (!(paramString.endsWith("WikiWikiWeb")))
                            break;
                          bool = false;
                        }
                        if (!(paramString.endsWith("UserPreferences")))
                          break;
                        bool = false;
                      }
                      if (!(paramString.endsWith("PhpWiki")))
                        break;
                      bool = false;
                    }
                    if (!(paramString.endsWith("WabiSabi")))
                      break;
                    bool = false;
                  }
                  if (!(paramString.endsWith("EditText")))
                    break;
                  bool = false;
                }
                if (!(paramString.endsWith("FindPage")))
                  break;
                bool = false;
              }
              if (!(paramString.endsWith("RecentChanges")))
                break;
              bool = false;
            }
            if (!(paramString.endsWith("RecentEdits")))
              break;
            bool = false;
          }
          if (!(paramString.endsWith("RecentVisitors")))
            break;
          bool = false;
        }
      while (!(paramString.endsWith("SteveWainstead")));
      bool = false;
    }
  }
}